import React, { PureComponent } from 'react'
import Redirect from 'umi/redirect'

class Index extends PureComponent {
  componentDidMount() {
    var deviceWidth
    setHtmlFont()
    if (window.addEventListener) {
      window.addEventListener('resize', function () {
        setHtmlFont()
      }, false)
    }
    function setHtmlFont() {
      deviceWidth = document.documentElement.clientWidth > 1920 ? 1920 : document.documentElement.clientWidth
      document.getElementsByTagName('html')[0].style.cssText = 'font-size:' + deviceWidth / 19.2 + 'px !important'
      window.addEventListener('banBackSpace')
    }
    // ---------------------------------------------------
  }
   getUrl = function () {
    const loginInfo = sessionStorage.getItem('loginInfo')
    if (loginInfo) {
      return '/workBench'
    } else {
      return '/login'
    }
  }

  render() {
    return <Redirect to={this.getUrl()} />
  }
}

export default Index
